<template>
	<div class="layout-sidebar-container" :class="{'is-collapse': collapse}">
		<Logo/>
		<el-scrollbar>
			<el-menu
				background-color="#001529"
				text-color="hsla(0,0%,100%,.65)"
				active-text-color="#fff"
				:default-active="activeMenu"
				:collapse="collapse"
				:unique-opened="true"
			>
				<sub-menu :menu-list="menuList"></sub-menu>
			</el-menu>
		</el-scrollbar>
	</div>
</template>

<script setup lang="ts">
import Logo from '../Logo/index.vue'
import {useSettingsStoreWithOut} from '@/stores/modules/settings'
import {computed} from "vue";
import { useAuthStoreWithOut} from "@/stores/modules/auth";
import { useRoute } from "vue-router";
import SubMenu from "./components/index.vue"


	defineOptions({
		name: 'SideBar'
	})
	const settingsStore = useSettingsStoreWithOut();
	const authStore = useAuthStoreWithOut()
	const route = useRoute() as Menu.MenuOptions

	const collapse = computed(()=> settingsStore.collapse);
	const themeConfig = computed(()=> settingsStore.themeConfig)
	const menuList = computed(()=> authStore.authMenuList)
	const activeMenu = computed(()=> route.meta.activeMenu ? (route.meta.activeMenu as string) : route.path)

</script>

<style scoped lang="scss">
@mixin active {
  &:hover {
    color: $base-color-white;
  }

  &.is-active {
    color: $base-color-white;
    background-color: var(--el-color-primary) !important;
  }
}

.layout-sidebar-container {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: $base-z-index;
  width: $base-left-menu-width;
  height: 100vh;
  background: $base-menu-background;
  box-shadow: 2px 0 6px rgb(0 21 41 / 35%);
  transition: width $base-transition-time;

  &.is-collapse {
    width: $base-left-menu-width-min;
    border-right: 0;
  }

  :deep(.el-scrollbar__wrap) {
    overflow-x: hidden;

    .el-menu {
      border: 0;
    }

    .el-menu-item,
    .el-submenu__title {
      height: $base-menu-item-height;
      overflow: hidden;
      line-height: $base-menu-item-height;
      text-overflow: ellipsis;
      white-space: nowrap;
      vertical-align: middle;
    }

    .el-menu-item {
      @include active;
    }
  }
}
</style>